﻿using AutoMapper;
using Hotel.Common;
using Hotel.IServices;
using Hotel.IServices.RequestDTO;
using Hotel.IServices.ResponseDTO;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Hotel.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    public class LoginController : ControllerBase
    {
        private readonly ILoginServies loginServies;
        private readonly ILogger<LoginController> logger;
        private readonly IMapper mapper;

        public LoginController(ILoginServies loginServies, ILogger<LoginController> logger, IMapper mapper)
        {
            this.loginServies = loginServies;
            this.logger = logger;
            this.mapper = mapper;
        }

        /// <summary>
        /// 登录
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        /// 
        [AllowAnonymous]
        [HttpPost]
        public async Task<ApiResult> LoginGoodsAsync(AddUserAsyncDto dto)
        {
          return await loginServies.LoginGoodsAsync(dto);

        }


        /// <summary>
        ///用户登录
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        /// 
        [HttpPost("UserLogin")]
        public async Task<ApiResult> UserLoginAsync(AddUserAsyncDto dto)
        {
            try
            {
                return await loginServies.UserLoginAsync(dto);
            }
            catch (Exception)
            {

                throw;
            }
        }
    }
}
